package cn.ruituo.adv8.server;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

public class FileThread extends Thread {
    private Socket s;
    public FileThread(Socket s){
        this.s=s;
    }

    @Override
    public void run() {
        System.out.println(s+"连接成功！");
        //发文件给你
        File file=new File("D:\\Documents\\图片和资料\\job-salary.png");
        try {
            FileInputStream fin=new FileInputStream(file);
            byte b[]=new byte[fin.available()];
            fin.read(b);
            fin.close();
            OutputStream out=s.getOutputStream();
            out.write(b);
            System.out.println("图片发送给"+s+"成功");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                s.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
